package com.hedl.practice.diyJava.genericity;

import com.hedl.practice.diyJava.genericity.utils.Person;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Study_Genericity_1 {
    public static void main(String[] args) {

        /*List list = new ArrayList();

        String[] ss = new String[]{ "Orange", "Apple", "Pear"};
        Arrays.sort(ss);
        System.out.println(Arrays.toString(ss));

        System.out.println("=======================");*/

        //自定义类，没有实现Comparable<String>接口。
        //报错：ClassCastException
        //实现：Comparable<Person>
        Person[] people = new Person[]{ new Person("Bob", 61),
                                        new Person("Alice", 88),
                                        new Person("Lily", 75),
                                        new Person("Xiao Ming",49),
                                        new Person("Zhang San",30),
                                        new Person("Li Si",90),
                                        new Person("Wang Wu",61)
        };
        Arrays.sort(people);
        System.out.println(Arrays.toString(people));
    }
}
